package com.aphrodite.io;

import java.util.Vector;

public final class CharBuffer {
	private Vector chars;
	private final int size;

	public CharBuffer(int size) {
		this.size = size;
		this.chars = new Vector();
	}

	public void addChar(char c) {
		chars.addElement(new Character(c));
	}

	public void clear() {
		chars.removeAllElements();
	}

	public boolean isFull() {
		return chars.size() == size;
	}

	public int size() {
		return chars.size();
	}

	public String toString() {
		char[] out = new char[size];
		for (int i = 0; i < size; i++) {
			Character character = (Character) chars.elementAt(i);
			out[i] = character.charValue();
		}
		return new String(out);
	}
}
